package com.java2104.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

//@ControllerAdvice //一个全局控制器的注解
public class GlobalExceptionHandler {

    //统一的异常处理
    @ExceptionHandler(Exception.class)
    public String handle(Exception ex, Model model) {
        model.addAttribute("err_msg", "对不起，程序出现错误：" + ex.getMessage());
        return "500";//跳转到一个显示500错误的页面
    }
}
